# Contributor: Mark Pashmfouroush <mark@markpash.me>
# Maintainer: Mark Pashmfouroush <mark@markpash.me>
pkgname=mage
pkgver=1.13.0
pkgrel=13
# Commit hash that corresponds to the version
_commit=3504e09d7fcfdeab6e70281edce5d5dfb205f31a
pkgdesc="make-like build tool using Go"
url="https://magefile.org/"
license="Apache-2.0"
arch="all"
depends="go"
options="chmod-clean net"
source="https://github.com/magefile/mage/archive/v$pkgver/mage-$pkgver.tar.gz"

export GOCACHE="${GOCACHE:-"$srcdir/go-cache"}"
export GOTMPDIR="${GOTMPDIR:-"$srcdir"}"
export GOMODCACHE="${GOMODCACHE:-"$srcdir/go"}"

build() {
	go build -o bin/mage -ldflags="
		-X \"github.com/magefile/mage/mage.timestamp=$(date -Ru${SOURCE_DATE_EPOCH:+d @$SOURCE_DATE_EPOCH})\"
		-X \"github.com/magefile/mage/mage.commitHash=$_commit\"
		-X \"github.com/magefile/mage/mage.gitTag=$pkgver\"
		"
}

check() {
	export GOROOT=/usr/lib/go
	go vet ./...
	go test -v -tags CI ./...
}

package() {
	install -Dm0755 bin/mage "$pkgdir/usr/bin/mage"
}

sha512sums="
a393a0192ecaf8664f9dd35acfd994993ab1c028a08fb8c925fc569ce58dc9d58baeef4760b012563e3f3a6957c77d548bb33a6b577d12af2e030e2465e6d24b  mage-1.13.0.tar.gz
"
